package tools;

import java.sql.*;

public class KoneksiDataBase {

    private static String jdbcURL = "jdbc:Oracle:thin:@172.23.9.185:1521:orcl";
    private static String user = "MHS105314089";
    private static String password = "MHS105314089";
    private static Connection connection;
//     private static String jdbcURL = "jdbc:Oracle:thin:@localhost:1521:XE";
//    private static String user = "system";
//    private static String password = "hr";
//    private static Connection connection = null;

    public KoneksiDataBase() {
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            connection = DriverManager.getConnection(jdbcURL, user, password);
            System.out.println("koneksi berhasil");
        } catch (Exception ex) {
            System.out.println("message: " + ex.getMessage());
        }
    }

    public static Connection getConnection() {
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            connection = DriverManager.getConnection(jdbcURL, user, password);
            System.out.println("koneksi berhasil");
        } catch (Exception ex) {
            System.out.println("message: " + ex.getMessage());
        }
        return connection;
    }

    public static void setConnection(Connection aConnection) {
        connection = aConnection;
    }
}
